package it.uniba.di.mas.jpnde.core;

import jade.util.leap.ArrayList;
import jade.util.leap.List;
import jade.util.leap.Serializable;

public class PNContext 
	implements Serializable{

	private static final long serialVersionUID = 1L;
	
	private String pnId=null;
	private String agentManagerId=null;
	private List tokens=null;
	
	public PNContext(String pnId,String agentManagerId){
		this.pnId=pnId;
		this.agentManagerId=agentManagerId;
		}

	public String getPnId() {
		return pnId;
	}

	public void setPnId(String pnId) {
		this.pnId = pnId;
	}
	
	public String getAgentManagerId() {
		return agentManagerId;
	}

	public void setAgentManagerId(String agentManagerId) {
		this.agentManagerId = agentManagerId;
	}

	public void setTokens(List tokens) {
		this.tokens = tokens;
	}

	public List getTokens() {
		return tokens;
	}
	
	public List getTokens(String placeId) {
		List ret=new ArrayList();
		for(int i=0;i<tokens.size();i++)
			if (((Token)tokens.get(i)).getPlaceId().equals(placeId))
				ret.add(tokens.get(i));
		return ret;
	}
	
	public Token[] getTokensAll(){
		Token[] ret=new Token[tokens.size()];
		for(int i=0;i<tokens.size();i++)
			ret[i]=(Token)tokens.get(i);	
		return ret;
	}
	
	public Token[] getTokensByPlace(String placeId){
		List _ret=getTokens(placeId);
		Token[] ret=new Token[_ret.size()];
		for(int i=0;i<_ret.size();i++)
			ret[i]=((Token)_ret.get(i));
		return ret;
	}
	
	@Override
	public String toString() {
		return "PNContext [pnId=" + pnId +", agentManagerId="+agentManagerId+"]";
	}
	
}
